package com.example.zhxy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zhxy.model.Admin;
import com.example.zhxy.service.AdminService;
import com.example.zhxy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * ClassName: AdminController
 * Package: com.example.zhxy.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-03-19
 * Time: 16:29
 */

@RestController
@RequestMapping("/sms/adminController")
public class AdminController {

    @Autowired
    private AdminService adminService;


    //管理员分页查询
    //GET
    //http://localhost:9001/sms/adminController/getAllAdmin/1/3?adminName=你
    @GetMapping("/getAllAdmin/{pageNo}/{pageSize}")
    public Result adminPage(@PathVariable("pageNo") Integer pageNo,
                            @PathVariable("pageSize") Integer pageSize,
                            String adminName){

        //创建分页构造器
        Page<Admin> page = new Page<>(pageNo,pageSize);

        IPage<Admin> iPage = adminService.getAdminPage(page,adminName);

        return Result.ok(iPage);
    }
}
